[DX] Support multi-mip Texture2D SRVs (#1039)#1230
Draft
alsepkow wants to merge 10 commits into
Draft
Conversation
Lifts the early-return guard on MipLevels > 1 for SRV textures and threads the mip count through to the D3D12_RESOURCE_DESC and the SRV's MipLevels field. Adds a per-mip upload path using GetCopyableFootprints so each subresource is copied with the correct D3D12_TEXTURE_DATA_PITCH_ALIGNMENT row pitch. The single-mip path is unchanged. RWTexture2D mips are still rejected with not_supported (no per-mip UAV support yet). Adds a new Texture2D.Load.MipMaps.test.yaml covering the 4x4 + 3-mip layout documented in docs/MipMappedTextures.md. Re-enables Texture2D.mips.OperatorIndex / Texture2D.OperatorIndex / Texture2D.GetDimensions on dxc-d3d12 and dxc-warp-d3d12 by qualifying the XFAIL to 'Clang && DirectX' for the unrelated Clang-DX path tracked in llvm/llvm-project#101558. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Addresses code review feedback on the multi-mip support change: the relaxed guard (changed from `!= 1` to `> 1 && !SRV`) silently accepted MipLevels values of 0 or negative integers. Since OutputProps.MipLevels is signed int, 0 would cast to a UINT(0) in the SRV desc (which D3D12 interprets as the magic "use all mip levels" value) and negative values would wrap to a huge uint16_t in the RESOURCE_DESC. Add an explicit lower-bound check so invalid input is rejected with a clear error instead of silently producing surprising behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Apply clang-format 19.1.6 to changed regions per pr-code-format CI.
Picks up the DriverVer fix (upstream llvm#1228) so clang-tidy stops failing on Device.cpp. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixes misc-const-correctness warnings-as-errors from clang-tidy in CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Skips non-texture resources where MipLevels is ignored downstream. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds D3D12 support for multi-mip
Texture2DSRVs, matching the existing Vulkan implementation. Tests can now declare aTexture2Dwith a populated mip chain and verify per-mip Load reads.Pipeline schema gains
OutputProperties.MipLevelsandResource.MostDetailedMip/Resource.MipLevelsfor the SRV view. The DX backend allocates the full mip chain viaD3D12_RESOURCE_DESC::MipLevels, drives per-mip uploads throughGetCopyableFootprintsfor the right row-pitch alignment, and configures the SRV withMostDetailedMip+MipLevelsfrom the YAML.Tests:
Texture2D.Load.Mips.testexercises per-mip loads across 3 mip levels. PASS ond3d12,warp-d3d12,vk(VK was already supported).Resolves #1039
Assisted by Claude Opus 4.7.